package com.zzyl.nursing.task;

import cn.hutool.core.collection.CollUtil;
import com.zzyl.nursing.domain.Elder;
import com.zzyl.nursing.mapper.ElderMapper;
import com.zzyl.nursing.service.INursingTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 定时护理任务的
 *
 * @Author mr.wei
 * @Data2025/8/711:39
 */
@Component
@Slf4j
public class AutoTask {
    @Autowired
    private INursingTaskService nursingTaskService;

    @Autowired
    private ElderMapper elderMapper;
    public void autoTask(){

        List<Elder> elderList = elderMapper.selectAll();
        if (CollUtil.isEmpty(elderList)){
            return;
        }
        //每个老人的任务生成一次
        elderList.forEach(elder -> {
            nursingTaskService.addNursingTask_v2(elder);
        });
        log.info("生成月任务成功");


    }
}
